<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/shop_configure.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">商铺配置</div>
                <div class="content">
                    <form id="putForm" method="put" enctype="multipart/form-data">
                        {{--<form action="{{ url('member/seller/shop_configure',['id'=>$sp_id])}}" id="putForm" method="put" enctype="multipart/form-data">--}}
                    {{ csrf_field()}}
                    <h3>店铺标识配置</h3>
                    <div class="identification">
                        <div class="item">
                            <div class="name">普通经销</div>
                            <div class="describe">
                                注册默认的店铺类型标签，具有开店的一般功能。
                            </div>
                            @if(in_array(1,$sp_type_id_arr))

                            <div class="success">
                                <img src="{{asset('/img/web/user/success01.png')}}">
                                开通店铺
                            </div>
                            @else

                            <div class="fail">
                                <img src="{{asset('/img/web/user/fail01.png')}}">
                                开通店铺
                            </div>
                            @endif

                            <div class="{{ in_array(1,$sp_type_id_arr)?'btn_success':'btn_apply'}} ">{{ in_array(1,$sp_type_id_arr)?'已通过':'申请'}} </div>
                        </div>
                        <div class="item">
                            <div class="name">合伙人店</div>
                            <div class="describe">
                                成功开店并成为城市伙人的商铺。
                            </div>
                            @if(in_array(2,$sp_type_id_arr))
                            <div class="success">
                                <img src="{{asset('/img/web/user/success01.png')}}">
                                成为合伙人
                            </div>
                            @else
                            <div class="fail">
                                <img src="{{asset('/img/web/user/fail01.png')}}">
                                成为合伙人
                            </div>
                            @endif
                            <div class="{{ in_array(2,$sp_type_id_arr)?'btn_success':'btn_apply'}} ">{{ in_array(2,$sp_type_id_arr)?'已通过':'申请'}}</div>
                        </div>
                        <div class="item">
                            <div class="name">网上博览</div>
                            <div class="describe">
                                申请成为网站博览会的商铺。
                            </div>
                            @if(in_array(3,$sp_type_id_arr))

                            <div class="success">
                                <img src="{{asset('/img/web/user/success01.png')}}">
                                报名线上博览会
                            </div>
                            @else

                            <div class="fail">
                                <img src="{{asset('/img/web/user/fail01.png')}}">
                                报名线上博览会
                            </div>
                            @endif
                            <div class="{{ in_array(3,$sp_type_id_arr)?'btn_success':'btn_add'}}">{{ in_array(3,$sp_type_id_arr)?'已通过':'马上报名'}}</div>
                        </div>
                        <div class="item">
                            <div class="name">厂家旗舰</div>
                            <div class="describe">
                                商家为制作工厂方，二三线品牌方。
                            </div>
                            @if(in_array(4,$sp_type_id_arr))
                            <div class="success">
                                <img src="{{asset('/img/web/user/success01.png')}}">
                                拥有自有品牌
                            </div>
                            @else
                            <div class="fail">
                                <img src="{{asset('/img/web/user/fail01.png')}}">
                                拥有自有品牌
                            </div>
                            @endif
                            <div class="{{ in_array(4,$sp_type_id_arr)?'btn_success':'btn_add'}}">{{ in_array(3,$sp_type_id_arr)?'已通过':'添加'}}</div>
                        </div>
                    </div>
                    <h3>商品交易配置</h3>
                    <div class="order">
                        <div class="item">
                            <div class="tit">下单订单付款超时限制</div>
                            <ul class="time_order" id="placeOrder">
                                <li data-id='7200' {{ $order_time==7200?"class=dq":"" }}>2小时</li>
                                <li data-id='21600' {{ $order_time==21600?"class=dq":"" }}>6小时</li>
                                <li data-id='43200' {{ $order_time==43200?"class=dq":"" }}>12小时</li>
                                <li data-id='86400' {{ $order_time==86400?"class=dq":"" }}>24小时</li>
                                <li data-id='259200' {{ $order_time==259200?"class=dq":"" }}>3天</li>
                                <li data-id='604800' {{ $order_time==604800?"class=dq":"" }}>7天</li>
                                <li data-id='1296000' {{ $order_time==1296000?"class=dq":"" }}>15天</li>
                                <li data-id='2592000' {{ $order_time==2592000?"class=dq":"" }}>30天</li>
                            </ul>
                            <input type="hidden" name="" class="placeOrderTime" value="{{ $order_time}}">
                            <div class="xian"></div>
                            <div class="tit">无理由退货时间限制</div>
                            <div class="choice cancel_orders">
                                <span {{ $return_time==0?"class=dq":"" }} data-id="0">不设定</span>
                                <span {{ $return_time==0?"":"class=dq" }} data-id="1">设定</span>
                            </div>
                            <input type="hidden" name="" class="cancelOrdersStatus" value="{{ $return_time==0?"0":"1" }}">
                            <div class="setting_box" {{ $return_time==0?"style=display:none;":"" }}>
                                <div class="input_box">
                                    <input type="text" class="cancelOrdersTime" data-id="{{ $return_time }}" value="{{ $return_time/86400 }}"  onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                                    <span>天</span>
                                </div>
                                <a>设定</a>
                                <font>不能超过订单超时限制</font>
                            </div>
                        </div>
                        <div class="item">
                            <div class="tit">收货订单确认超时限制</div>
                            <ul class="time_order" id="confirmOrder">
                                <li data-id='7200' {{ $receipt_time==7200?"class=dq":"" }}>2小时</li>
                                <li data-id='21600' {{ $receipt_time==21600?"class=dq":"" }}>6小时</li>
                                <li data-id='43200' {{ $receipt_time==43200?"class=dq":"" }}>12小时</li>
                                <li data-id='86400' {{ $receipt_time==86400?"class=dq":"" }}>24小时</li>
                                <li data-id='259200' {{ $receipt_time==259200?"class=dq":"" }}>3天</li>
                                <li data-id='604800' {{ $receipt_time==604800?"class=dq":"" }}>7天</li>
                                <li data-id='1296000' {{ $receipt_time==1296000?"class=dq":"" }}>15天</li>
                                <li data-id='2592000' {{ $receipt_time==2592000?"class=dq":"" }}>30天</li>
                            </ul>
                            <input type="hidden" name="" class="confirmOrderTime" value="{{ $receipt_time }}">
                            <div class="xian"></div>
                            <div class="tit">库存对用户下单的限制</div>
                            <div class="choice stock_orders">
                                <span {{ $stock_time==0?"class=dq":"" }} data-id="0">不限制</span>
                                <span {{ $stock_time==0?"":"class=dq" }} data-id="1">限制</span>
                            </div>
                            <input type="hidden" name="" class="stockOrdersStatus" value="{{ $stock_time==0?"0":"1" }}">
                            <div class="limit_box" {{ $stock_time==0?"style=display:none;":"" }}>
                                <span data-id = "1" {{ $stock_time==1?"class=dq":"" }}>下单成功时锁定库存</span>
                                <span data-id = "2" {{ $stock_time==2?"class=dq":"" }}>付款成功时锁定库存</span>
                            </div>
                            <input type="hidden" name="" class="limit" @if($stock_time==1)value="1"@elseif($stock_time==2)value="2"@else value=""@endif>
                        </div>
                    </div>
                    <h3>商铺优化配置</h3>
                    <div class="optimization_tit">商铺标题</div>
                    <input type="text" value="{{$sp_title}}" name="sp_title" class="optimization_input optimization_title" placeholder="标题设置，建议不要超过26个字符。" maxlength="26" >
                    <div class="optimization_tit">店铺关键字</div>
                    <input type="text" name="key_words" class="optimization_input keyword"  value="{{$key_words}}" placeholder="可以设置多个关键词，请以逗号隔开； 如硬盘，摄像机，网卡">
                    <div class="optimization_tit">店铺描述</div>
                    <textarea class="optimization_textarea shopDescribe"  name="description" placeholder="简短描述企业简介或者主营产品的相关信息。">{{$description}}</textarea>
                    <input type="button" class="tijiao" value="提交"  />
                </form>
                </div>
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')
<script>
$(function () {
    var stock_time='{{$stock_time}}';
    var order_time='{{$order_time}}';
    var receipt_time='{{$receipt_time}}';
    var return_time='{{$return_time}}';
    // 下单订单付款超时限制
    $("#placeOrder li").click(function () {
        $(this).addClass("dq").siblings().removeClass("dq");
        $(".placeOrderTime").val($(this).attr('data-id'));
        order_time= $(".placeOrderTime").val();

    })

    // 无理由退货时间限制
    $(".cancel_orders span").click(function () {
        $(this).addClass("dq").siblings().removeClass("dq");
        if($(this).attr('data-id') == 1){
            $('.setting_box').show();
        }else{
            $('.cancelOrders').val('');
            $('.setting_box').hide();
        }
        $(".cancelOrdersStatus").val($(this).attr('data-id'));
    })

    $(".cancelOrdersTime").change(function(){
        var tian=$(this).val();
        var miao=tian * 86400;
        $(this).attr('data-id',miao);
    });

    // 收货订单确认超时限制
    $("#confirmOrder li").click(function () {
        $(this).addClass("dq").siblings().removeClass("dq");
        $(".confirmOrderTime").val($(this).attr('data-id'));
        receipt_time=$(".confirmOrderTime").val();
    })

    // 库存对用户下单的限制
    $(".stock_orders span").click(function () {
        $(this).addClass("dq").siblings().removeClass("dq");
        if($(this).attr('data-id') == 1){
            $('.limit_box').show();
        }else{
            $('.limit_box span').removeClass("dq");
            $(".limit").val('');
            $('.limit_box').hide();
            stock_time=0;
        }
        $(".stockOrdersStatus").val($(this).attr('data-id'));
    })

    //下单成功时锁定库存,付款成功时锁定库存选择
    $(".limit_box span").click(function () {
        $(this).addClass("dq").siblings().removeClass("dq");
        $(".limit").val($(this).attr('data-id'));
        stock_time=$(".limit").val();

    })

    $(".tijiao").click(function () {

        if($("#placeOrder li").is(".dq") == false) {
            layer.alert('请选择下单订单付款超时限制', {
                title: '温馨提示'
            });
            return false;
        }

        if($('.cancelOrdersStatus').val() == 1){
            if($('.cancelOrdersTime').val() == "" || $('.cancelOrdersTime').val() == 0){
                layer.alert('请设置不能超过订单超时限制的时间', {
                    title: '温馨提示'
                });
                return false;
            }
        }

        if($('.cancelOrdersStatus').val() == 1 && $('.cancelOrdersTime').val() != ""  && $('.cancelOrdersTime').attr('data-id') - $('.placeOrderTime').val() > 0){
            layer.alert('无理由退货时间不能超过订单超时时间', {
                title: '温馨提示'
            });
            return false;
        }
        if($("#confirmOrder li").is(".dq") == false) {
            layer.alert('请选择收货订单确认超时限制', {
                title: '温馨提示'
            });
            return false;
        }


        if($('.stockOrdersStatus').val() == 1 && $(".limit").val() == ''){
            layer.alert('请设置锁定库存方式', {
                title: '温馨提示'
            });
            return false;
        }

        if ($(".optimization_title").val() == '') {
            layer.alert('请输入商铺标题', {
                title: '温馨提示'
            });
            return false;
        }

        if ($(".keyword").val() == '') {
            layer.alert('请输入店铺关键字', {
                title: '温馨提示'
            });
            return false;
        }

        if ($(".shopDescribe").val() == '') {
            layer.alert('请输入店铺描述', {
                title: '温馨提示'
            });
            return false;
        }

        if($('.cancelOrdersStatus').val() == 1){
            return_time=$('.cancelOrdersTime').attr('data-id');
        }else{
            return_time=0;
        }
        var sp_title = $(".optimization_title").val();
        var key_words = $(".keyword").val();
        var description = $(".shopDescribe").val();

        var edit_id="{{$sp_id}}" ;
        $.ajax({
            url : '{{Request::url()}}/'+edit_id,
            type : 'put',
            dataType : "json",
            data : {sp_title:sp_title,key_words:key_words,description:description,order_time:order_time,receipt_time:receipt_time,return_time:return_time,stock_time:stock_time},
            success : function(data) {
//                alert(data)
                if (0 == data.code) {
                    layer.alert("修改成功", {
                        icon: 1
                    }
//                            , function () {
//                        location.reload();
////                        alert(1);
//                    }
                    );
                } else {
                    layer.alert(data.message, {
                        icon: 2
                    });
                }
            }
        });





    });


})
</script>
</body>
</html>